<?php
class Passwordverify extends Controller {
	private $password;
	private $username;
	private $TBL_NAME = 'users';
	function index() {
		$this -> password = $_POST['password'];
		$this -> username = $_POST['username'];
		$this -> load -> database();
		$this -> load -> helper('url');
		
		if ( $this -> correctPassword($this -> username,$this -> password) ) {
			redirect('mainpage');
		} else {
			redirect('login');
		}
	}

	function correctPassword($user,$pass) {
		$query = $this->db->get($this -> TBL_NAME);
		foreach($query->result() as $row) {
			if ( $row -> username == $user && $row -> password == $pass)
				return true;
		}
		return false;
	}


}

?>